package com.guomao.entity;

import com.guomao.utils.DrawUtils;

import java.io.IOException;

public abstract class Element {

    public int hp;
    public int x;
    public int y;

    public int width;
    public int height;

    public String path;

    public Element(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Element() {

    }

    public void getSize() {
        try {
            int[] size = DrawUtils.getSize(path);
            this.width = size[0];
            this.height = size[1];
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void draw() {
        try {
            DrawUtils.draw(path, x, y);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
